/**
 * 
 */
package com.deitel.advjhtp1.gui.splitpane;

import java.awt.BorderLayout;
import java.awt.Container;

import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;

import com.deitel.advjhtp1.gui.webbrowser.WebBrowserPane;
import com.deitel.advjhtp1.gui.webbrowser.WebToolBar;

/**
 * @author Aslanbek
 *
 */
public class FavoritesWebBrowser extends JFrame {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 9139302118152777093L;
	private WebToolBar toolBar;
	private WebBrowserPane browserPane;
	private WebBrowserPane favoritesBrowserPane;
	
	public FavoritesWebBrowser()
	{
		super("AsChrome Web Browser");
		
		browserPane = new WebBrowserPane();
		toolBar = new WebToolBar(browserPane);
		
		favoritesBrowserPane = new WebBrowserPane();
		
		favoritesBrowserPane.addHyperlinkListener(toolBar);
		
		favoritesBrowserPane.goToURL(getClass().getResource("http://www.google.com"));
		
		JSplitPane splitPane = new JSplitPane(
				JSplitPane.HORIZONTAL_SPLIT,
				new JScrollPane(favoritesBrowserPane),
				new JScrollPane(browserPane));
		
		splitPane.setDividerLocation(210);
		
		splitPane.setOneTouchExpandable(true);
		
		Container contentPane = getContentPane();
		contentPane.add(toolBar, BorderLayout.NORTH);
		contentPane.add(splitPane, BorderLayout.CENTER);
	}

	public static void main(String args[])
	{
		FavoritesWebBrowser browser = new FavoritesWebBrowser();
		browser.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		browser.setSize(640, 480);
		browser.setVisible(true);
	}
}
